<%@ page language="java" pageEncoding="UTF-8" isErrorPage="true" contentType="text/html; charset=utf-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">   
.quit {width: 67px;height: 25px;background-image:url(./images/quit02.png);background-repeat:no-repeat;background-position: 0 50%;background-attchment:fixed;}
a.quit:link {color: gray;font-size:14px;display:block;padding-top: 4px;text-decoration:none;}
a.quit:hover{color: red;font-size:14px;display:block;padding-top: 4px;text-decoration:underline;}
a.quit:visited{color: gray;font-size:14px;display:block;padding-top: 4px;text-decoration:none;}
</style>   
<title> 幼儿园管理系统</title>
<link rel="stylesheet" type="text/css" href="script/ext-2.0.2/resources/css/ext-all.css" />
<script type="text/javascript" src="script/ext-2.0.2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="script/ext-2.0.2/ext-all.js"></script>
<script type="text/javascript" src="script/ext-2.0.2/ext-lang-zh_CN.js"></script>


<script type="text/javascript">   

	Ext.BLANK_IMAGE_URL = "script/ext-2.0.2/resources/images/default/s.gif";
	//点击菜单显示页面
	function treeClick(id,text, path){
		var index = contentPanel.items.getCount();
		var n = contentPanel.getComponent(id);
		if (!n) { //判断是否已经打开该面板
			if(index >= 10){
				Ext.Msg.alert("窗口提示","为了确保浏览效果，页面不允许同时打开超过10个窗口，请关闭不需要的窗口后再操作！");
			}else{
				n = contentPanel.add({
					'id':id,
					'title':text,
					closable:true, //通过html载入目标页
					html:'<iframe scrolling="auto" frameborder="0" name="'+id+'Frame"  width="100%" height="100%" src="'+path+'"></iframe>'
				});
				index ++;
			}
		}
		//if(index <= 10)
		contentPanel.setActiveTab(n);
	}
	//右边tab容器
	var contentPanel  =  new Ext.TabPanel({
								region:'center',
								enableTabScroll:true,
								width: "100%",
								height: "100%",
								activeTab:0,
								items:[{
									title: '主页',
									autoScroll:true,
									html:'<iframe scrolling="auto" frameborder="0"  width="100%" height="100%" src="./jsp/frame/Main.jsp"></iframe>'
								}]

							});
	
	//双击关闭TabPanel标签页
	Ext.override(Ext.TabPanel, {
		    initEvents : function(){
	        Ext.TabPanel.superclass.initEvents.call(this);
	        this.on('add', this.onAdd, this);
	        this.on('remove', this.onRemove, this);
	        this.strip.on('mousedown', this.onStripMouseDown, this);
	        this.strip.on('contextmenu', this.onStripContextMenu, this);
	        this.strip.on('dblclick', this.onTitleDbClick, this);
	        if(this.enableTabScroll){             
	        	this.strip.on('mousewheel', this.onWheel, this);
	        }
		},
		onTitleDbClick:function(e,target,o){   
			var t = this.findTargets(e);  
			if (t.item.fireEvent('beforeclose', t.item) !== false && t.item.closable!==false) {   
				t.item.fireEvent('close', t.item);   
				this.remove(t.item);
			}
		}
	});  
//获得菜单
	function getMenu(){
		Ext.Ajax.request({
                url:'./menu!oneMenu.action',
                success: function(o){        
                    if(typeof o == 'object'){
                        var d = Ext.util.JSON.decode(o.responseText);
                        	if(d.length>0)                     	
                            for(var i=0;i<d.length;i++){
                                Ext.getCmp('west-panel').add(
                                new Ext.Panel({
											border:false,
											autoScroll:true,
											layout:'fit',
											id : d[i].menuid,
											title:'<div id=menubar>'+d[i].menuname+'</div>',
											collapseFirst:false,
											listeners:{
												'beforeexpand':function(p){                          
													var root=p.items.first().root;
													if(root.allow!=true){
														root.allow=true;
														root.reload();
													}
													root.expand(true,false);
													activeMenuTabId = this.id;
												}
											},
											items:[new Ext.tree.TreePanel({
												height:200,
												useArrows:true,
												autoScroll:true,
												animate:true,
												enableDD:false,
												border:false,
												rootVisible:false,
												containerScroll:true,
												border:false,
												listeners:{
													'click':function(p){
														if(p.attributes.location){  
															treeClick(p.attributes.id,p.attributes.text,p.attributes.location);
														}
													}
												},
												loader:new Ext.tree.TreeLoader({
														  dataUrl:'security',
														  root:'list',
														  listeners : {
															  'beforeload' : function(treeLoader, node) {
																		   if(node.attributes.index!=0&&node.parentNode==null&&node.allow!=true){
																				return false;
																			}else{
																				node.allow=true;
																			}
																   treeLoader.dataUrl='/children/menu!getMoreMenu.action?node='+node.id;
															 }
														  }
													   }),
												root:new Ext.tree.AsyncTreeNode({id :d[i].menuid,text :d[i].menuname, index:i, draggable:false })   
												})]
                                }));
                            }
                            Ext.getCmp('west-panel').doLayout(true);
                    }
                }
                , failure: function(){
                    Ext.Msg.alert("提示","无法访问服务器");
                }
            });       
	}

	    
    Ext.onReady(function(){
	   Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
       var viewport = new Ext.Viewport({
            layout:'border',
            items:[
                new Ext.BoxComponent({ // raw
                    region:'north',
                    el: 'north',
                    height:35
                }),{
	                    region:'west',
	                    id:'west-panel',
						name:'west-panel',
	                    split:true,
	                    width: 200,
	                    minSize: 175,
	                    maxSize: 400,
	                    title:'菜单', 
	                    collapsible: true,
	                    layout:'accordion',
	                    layoutConfig:{
	                        animate:true
	                    },
				        margins:'0 0 5 5',
				        cmargins:'0 0 0 0',
				        rootVisible:false,
				        lines:false,
				        autoScroll:true,
				        animCollapse:false,
				        animate: false,
				        collapseMode:'mini'
                    },
               contentPanel
             ]
        });
        getMenu();
    });
</script>   
</head>   
<body>
	<form name="login" action="logout.shtml" method="post" target="_top">
     <table width=100% id="north" border="0" cellpadding="0" cellspacing="0" height="15" bgcolor="#dfe8f6">
     <tr><td colspan=2 width=100% height=2px bgcolor="#b8cfee"></td></tr>
     <tr>
     <td width=95% nowrap style="color: #15428b; font-weight: bold; font-size: 16px;">&nbsp;&nbsp;幼儿园案理系统</td>  
     <td align="center" width=5%><a href="javascript:login.submit();" class="quit">退&nbsp;出</a></td>
     </tr>
     </table>
</form>
</body>

</html>

